<!-- 按钮 -->
<template>
    <div class="button" :style="boxStyle">
        {{ element.eles.content }}
    </div>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
export default defineComponent({
    name: 'WidgetButton',
    props: {
        element: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props, { emit }) {
        const { element } = toRefs(props)

        const boxStyle = computed(() => {
            const style = element.value.eles.style || {}
            return {
                width: style.width,
                height: style.height,
                color: style.color,
                opacity: style.opacity,
                fontSize: style['font-size'],
                fontStyle: style['font-style'],
                fontWeight: style['font-weight'],
                textAlign: style['text-align'],
                textDecoration: style['text-decoration'],
                lineHeight: style['line-height'],
                marginTop: style['margin-top'],
                marginBottom: style['margin-bottom'],
                marginLeft: style['margin-left'],
                marginRight: style['margin-right'],
                borderStyle: style['border-style'],
                borderColor: style['border-color'],
                borderWidth: style['border-width'],
                borderRadius: style['border-radius'],
                backgroundColor: style['background-color'],
                backgroundImage: style['background-image'],
                boxShadow: style['box-shadow']
            }
        })
        
        return {
            element,
            boxStyle
        }
    }
})
</script>

<style lang="less" scoped>
@import './widget-button.less';
</style>